<template>
    <div class="vip-card-container">
        <img :src="vipList.imgUrl" alt="">
        <div class="card-intro">
            <p>{{vipList.text}}</p>
            <p class="price">¥{{vipList.price}}/张</p>
        </div>
        <div class="card-detail-intro">
            <h3>商品介绍</h3>
            <ul>
                <li>每日听书年费VIP实体卡<span>激活有效期为365天</span>，如若未在有效期之内激活则卡片失效。（<span>具体有效期以实体卡面显示为准</span>）</li>
                <li>每日听书年费VIP实体卡<span>使用有效期为365天</span>，从激活当天计算时间</li>
                <li>单次购买每日听书年费实体卡数量不能低于<span>5张</span>。</li>
                <li>商品购买完成后“懂行”将提供“包邮”服务~（部分地区由于地域问题无法进行包邮服务如:新疆，西藏，内蒙古，青海，海南，宁夏。敬请谅解！）</li>
            </ul>
        </div>
        <div class="footer-box" @click="buyCard">立即购买</div>
        <com-dialog v-if="isShow" :dialogConent="dialogConent" @leftBtn="cancelBtn" @rightBtn="sureBtn" :cur="cur"></com-dialog>
        <buy-box v-if="isBuy" :price="vipList.price" @sureBuy="sureBuy"></buy-box>
    </div>
</template>
<script>
    import comDialog from '@/components/comDialog.vue'
    import buyBox from '../buyBox.vue'
    import market from '@/api/market.js'
    import cookie from '../../../../util/cookie.js'
    export default {
        components: {
            comDialog,
            buyBox
        },
        data () {
            return {
                isShow: false,
                dialogConent: {
                    title: '是否确认订单',
                    left: '取消',
                    right: '确定'
                },
                cur: 0,
                isBuy: false,
                price: 1156.00,
                vipList: ''
            }
        },
        created () {
            market.getcardInfo(JSON.parse(localStorage.getItem('dongHang_data')).agentId).then(res => {
                if (res.code == 0) {
                    this.vipList = res.t
                    cookie.set('img', res.t.imgUrl)
                    cookie.set('vipcardprice', this.vipList.price)
					cookie.set('vipcardprice', this.vipList.price);
				    this.price = this.vipList.price;
                }
            })
        },
        methods: {
            buyCard () {
                this.isBuy = true
            },
            cancelBtn () {
                setTimeout(() => {
                    this.isShow = false
                }, 200)
            },
            sureBtn () {
                setTimeout(() => {
                    this.$router.push('/sure')
                }, 200)
            },
            sureBuy (obj) {
                cookie.set('num', obj.num)
                cookie.set('allprice', obj.all)
                this.isBuy = false
                this.isShow = true
            }
        }
    }
</script>
<style lang="less" scoped>
    .vip-card-container {
        padding: 0.4rem 0.3rem;
        margin-bottom: .88rem;
        overflow: auto;
        img {
            width: 6.9rem;
        }
        .card-intro {
            p {
                color: #282828;
                font-size: 0.3rem;
            }
            .price {
                color: #ff2d41;
                font-size: 0.4rem;
                margin-top: 0.1rem;
            }
        }
        .card-detail-intro {
            margin-top: 0.4rem; 
            h3 {
                color: #282828;
                font-size: 0.3rem;
                font-weight: normal;
                margin-bottom: 0.2rem;
            }
            ul {
                font-size: 0.26rem;
                color: #707070;
                li {
                    text-align: justify;
                    line-height: 0.48rem;
                    &::before {
                        content: '';
                        display: inline-block;
                        width: 0.2rem;
                        height: 0.2rem;
                        background: #707070;
                        border-radius: 0.2rem;
                        margin-right: 0.1rem;
                    }
                    span {
                        color: #ff2d41;
                    }
                }
            }
        }
        .footer-box {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 0.8rem;
            line-height: 0.8rem;
            text-align: center;
            background: #29abae;
            color: #fff;
            font-size: 0.32rem;
        }
    }
</style>